package com.xfp.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.xfp.mapper.OrderMapper;
import com.xfp.method.pageTotal;
import com.xfp.pojo.dto.OrderQueryDto;
import com.xfp.pojo.entity.Order;
import com.xfp.pojo.vo.GoodsList;
import com.xfp.pojo.vo.OrderQueryVo;
import com.xfp.pojo.vo.PartnerQueryVo;
import com.xfp.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    /**
     * 订单搜索
     * @param dto
     * @return
     */
    @Override
    public OrderQueryVo orderQuery(OrderQueryDto dto) {
        PageHelper.startPage(dto.getPageIndex(),dto.getPageSize());
        Page<Order> page = orderMapper.orderQuery(dto);
        return new OrderQueryVo(dto.getPageIndex(),dto.getPageSize(), pageTotal.total(page.getTotal(), dto.getPageSize()),page.getTotal(),page.getResult());
    }

    /**
     * 获取售货机商品销量
     * @param innerCode
     * @param start
     * @param end
     * @return
     */
    @Override
    public List<GoodsList> getSkuCollect(String innerCode, String start, String end) {
        return orderMapper.getSkuCollect(innerCode,start,end);
    }
}
